package com.lebang.model.back;

import com.lebangweb.encrypt.MessageDigestUtil;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * @Author: hwq
 * @Date: 2021/1/4 10:41
 * @Version 1.0
 */
@Data
public class AdCallback {
    /**
     * 订单号
     */
    private String orderId;
    /**
     * 用户id
     */
    private String memberId;
    /**
     * 奖励值
     */
    private int money;
    /**
     * 奖励类型0分1金币
     */
    private Integer rewardType;
    /**
     * 任务类型
     */
    private String category;
    /**
     * 提示语
     */
    private String msg;
    /**
     * 签名
     */
    private String sign;

    private String appStore;
    private String version;
    private String imei;
    private String ua;
    private String ipAddress;
    private String mac;
    private LocalDateTime createTime;
    /**
     * 验证签名
     * @param
     * @return
     * @throws Exception
     */
    public boolean checkSign()  {
        String mySign= null;
        try {
            mySign = MessageDigestUtil.encryptMD5((orderId + memberId + money + rewardType + category + "XMLB8888.!").getBytes()).toUpperCase();
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return mySign.equals(sign);
    }

    /**
     * 生成签名
     * @param
     * @throws Exception
     */
    public void createSign()  {
        try {
            this.sign= MessageDigestUtil.encryptMD5((orderId + memberId + money + rewardType + category + "XMLB8888.!").getBytes()).toUpperCase();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
